<?php

use App\Models\Activity\ActivityActionModel;
use App\Models\Activity\ActivityShopJoinModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateActivityShopJoin extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_shop_join', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger("shopId")->comment("门店id (shop.id)")->default(0);
            $table->unsignedBigInteger("activityId")->comment("活动id (activity.id)")->default(0);
            $table->unsignedBigInteger("activityActionId")->comment("活动行为表 (activity_action.id)")->default(0);
            $table->unsignedTinyInteger("actionType")->comment(
                enumToMigrationComment(ActivityActionModel::ACTION_TYPE_TEXT)
            )->default(0);
            $table->string("orderNo")->comment("关联单号 [ 支付:订货单号 | 表单: cruise_order.id ]")->default("");
            $table->string("uuid", "64")->comment("uuid")->default("");
            $table->string("address")->comment("支付行为 - 回调的收货地址信息")->default("");

            $table->unsignedTinyInteger("feedbackStatus")->comment(
                enumToMigrationComment(ActivityShopJoinModel::FEEDBACK_STATUS_TEXT, "回传状态")
            )->default(0);
            $table->unsignedInteger("feedbackTime")->comment("回传时间")->default(0);
            $table->unsignedBigInteger("feedbackUid")->comment("回传提交用户uid")->default(0);
            $table->string("feedbackUsername", 120)->comment("回传提交用户名称")->default("");

            $table->string('approveUsername', 120)->default("")->comment("审批人姓名 [ 表单行为:审批人 | 支付行为: 无 ]");
            $table->unsignedBigInteger('approveUseId')->default(0)->comment("审批人uid [ 表单行为:审批人 | 支付行为: 无 ]");

            $table->string('submitUsername', 120)->default("")->comment("提交时间 [ 表单行为:提交人名称 | 支付行为: 发起支付人名称 ]");
            $table->unsignedBigInteger('submitUseId')->default(0)->comment("提交人uid [ 表单行为:提交人uid | 支付行为: 发起支付人uid ]");


            $table->unsignedTinyInteger("status")->comment(
                enumToMigrationComment(ActivityShopJoinModel::STATUS_TEXT, "参与状态")
            )->default(0);
            $table->unsignedInteger('joinTime')->default(0)->comment('参与时间 [支付行为: 支付时间 | 表单行为: 审批通过时间]');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->unsignedTinyInteger('isDeleted')->default(0)->comment('是否删除 0 否 1是');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '活动 - 门店参与表';

            $table->index(["activityId", "shopId"], "idx_activityId_shopId");
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('activity_shop_join');
    }
}
